
#include <iostream>

#include "Master.h"
#include "Messenger.h"
#include "Screen.h"
#include "PlatformFactory.h"

Master::Master(std::string remote_ip, int port)
{
    message_index = 1;
    messenger_ = new Messenger(remote_ip, port);
};

Master::~Master()
{
    delete messenger_;
}

void Master::Start()
{
	Screen screen = PlatformFactory::GetScreen();
	MncPoint screen_bounds = screen.GetSize();
}

void Master::Stop()
{

}

void Master::MouseEventOccured(abyte event_type, abyte move_type, uint32_t timestamp, short x, short y, short wheel_delta)
{
	Message message = Message();
    message.time_stamp = message_index++;
    message.event_type = event_type;
    message.x = x;
    message.y = y;
	message.wheel_delta = wheel_delta;
	message.coordinate_type = move_type;
	//char dbg[64] = {0};
	//sprintf(dbg, "Sending message: %hd, %hd\n", message.x, message.y);
	//OutputDebugStringA(dbg);
	messenger_->Send(message);
}